<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<link href="../css/mui.min.css" rel="stylesheet" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<style>
			html,
			body {
				width: 100%;
				height: 100%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="background-color: #007AFF;width: 100%;height: 10%;">
			<a class="mui-pull-left" href="#popover" style="width: 20%;height: 50%;padding:0px;margin-top: 5%;color: #007AFF;">
				<p style="color:#FFFFFF;width: 100%;font-size:110%;display: inline">上海</p>
				<span class="mui-icon mui-icon-arrowdown" style="width: 20%;text-align: center;font-size: 70%;color: #FFFFFF;" />
			</a>

			<span class="mui-icon mui-icon-search mui-pull-right" style="width: 1rem;height: 1rem;padding:0.05rem;color: #007AFF;margin-top: 0.75rem;text-align: center;margin-right: 0.1rem;border-radius:1rem;background-color: #FFFFFF;"></span>

			<div id="popover" class="mui-popover mui-bar-popover" style="width: 30%;margin-top: 1.4rem;">
				<div class="mui-popover-arrow"></div>
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a href="#">上海</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#">北京</a>
					</li>
					<li class="mui-table-view-cell">
						<a href="#">杭州</a>
					</li>
				</ul>
			</div>

		</header>
		<div class="mui-content" style="position: absolute;top: 10%;padding-top: 0px;height: 90%;width: 100%;">
			<div style="padding: 10px 10px;">
				<div id="segmentedControl" class="mui-segmented-control">
					<a class="mui-control-item mui-active" href="#item1">
						政策扶持
					</a>
					<a class="mui-control-item" href="#item2">
						近期活动
					</a>
				</div>
			</div>
			<div style="height: 90%;width: 100%;">
				<div id="item1" class="mui-control-content mui-active" style="height: 100%;width: 100%;width: 100%;">
					<div id="scroll1" class="mui-scroll-wrapper" style="width: 100%;">
						<div class="mui-scroll">
							<ul id="list1" class="mui-table-view" style="height: 100%;width: 100%;">
							</ul>
						</div>
					</div>

				</div>
				<div id="item2" class="mui-control-content mui-active" style="height: 100%;">
					<div id="scroll2" class="mui-scroll-wrapper" style="width: 100%;">
						<div class="mui-scroll" style="width: 100%;">
							<ul id="list2" class="mui-table-view" style="height: 100%;width: 100%;">
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery-1.11.0.js"></script>
		<script src="../js/rem.js"></script>
		<script src="../js/mui.lazyload.js"></script>
		<script src="../js/mui.lazyload.img.js"></script>
		<script src="../js/initData.js"></script>
		<script type="text/javascript">
			var list1 = document.getElementById("list1");
			var list2 = document.getElementById("list2");

			function getData() {
				mui.ajax(url_get_policy, {
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						plus.nativeUI.closeWaiting();
						//服务器返回响应，根据响应结果，分析是否登录成功；
						var json_value = JSON.parse(data);
						console.log("政策 " + data);
						var body = json_value.value;
						for(i = 0; i < body.length; i++) {
							var li1 = document.createElement("li");
							li1.className = "mui-table-view-cell";
							var content = removeHTMLTag(body[i].content);
							li1.style.width = "100%";
							li1.style.height = "10em";
							li1.style.padding = "0px";
							li1.style.margin = "0px";
							li1.innerHTML = '<div class="mui-media-large" style="width: 100%; height: 100%;padding: 3%;position: relative;"> <img data-lazyload=' + body[i].images + ' style="width: 40%; height: 100%;"/><div class = "mui-pull-right" style = "height: 100%;width:60%;padding:1%;color: #000000;" ><p style = "font-size: 1em;margin-top:5%;height:5em;color:#000000;">' + body[i].title + '</p><p class = "mui-ellipsis-2" style = "font-size: 70%;">' + content + '</p><br/><span class = "mui-icon mui-icon-chatboxes" style = "font-size: 100%;">0</span> <span class = "mui-icon mui-icon-chat" style = "font-size: 100%;margin-left:20%;">0</span></div> </div>';
							li1.setAttribute("bodyid", body[i].id);
							li1.addEventListener("tap", function() {
								var bodyid = this.getAttribute("bodyid");
								plus.nativeUI.showWaiting("请稍等加载中。。");
								console.log(bodyid);
								plus.webview.create("news_page.html", "", "", {
									nnn_id: bodyid
								});
							});
							list1.appendChild(li1);
						};
						mui(".mui-table-view-cell").imageLazyload({
							placeholder: '../image/loading.jpg'
						});
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(type);
						console.log("home" + errorThrown);
						plus.nativeUI.closeWaiting();
					}
				});
				mui.ajax(url_get_activity, {
					type: 'get', //HTTP请求类型
					timeout: 10000, //超时时间设置为10秒；
					success: function(data) {
						plus.nativeUI.closeWaiting();
						//服务器返回响应，根据响应结果，分析是否登录成功；
						var json_value = JSON.parse(data);
						console.log("活动" + data);
						var body = json_value.value;
						for(i = 0; i < body.length; i++) {
							var li2 = document.createElement("li");
							var content = removeHTMLTag(body[i].content);
							li2.className = "mui-table-view-cell";
							li2.style.width = "100%";
							li2.style.height = "10em";
							li2.style.padding = "0px";
							li2.style.margin = "0px";
							li2.innerHTML = '<div class="mui-media-large" style="width: 100%; height: 100%;padding: 3%;position: relative;"> <img data-lazyload=' + body[i].images + ' style="width: 40%; height: 100%;"/><div class = "mui-pull-right" style = "height: 100%;width:60%;padding:1%;color: #000000;" ><p style = "font-size: 1em;margin-top:5%;height:5em;color:#000000;">' + body[i].title + '</p><p class = "mui-ellipsis-2" style = "font-size: 70%;">' + content + '</p><br/><span class = "mui-icon mui-icon-chatboxes" style = "font-size: 100%;">0</span> <span class = "mui-icon mui-icon-chat" style = "font-size: 100%;margin-left:20%;">0</span></div> </div>';
							li2.setAttribute("bodyid", body[i].id);
							li2.addEventListener("tap", function() {
								var bodyid = this.getAttribute("bodyid");
								plus.nativeUI.showWaiting("请稍等加载中。。");
								plus.webview.create("news_page.html ", "", "", {
									nnn_id: bodyid
								});
							});
							list2.appendChild(li2);
						};
						mui(".mui-table-view-cell ").imageLazyload({
							placeholder: '../image/loading.jpg'
						});
					},
					error: function(xhr, type, errorThrown) {
						//异常处理；
						console.log(type);
						console.log("home " + errorThrown);
						plus.nativeUI.closeWaiting();
					}
				});
			}
			mui.init();
			mui.plusReady(function() {
				mui('.mui-scroll-wrapper').scroll({
					indicators: true, //是否显示滚动条
					bounce: false
				});
				document.addEventListener('touchstart', function(e) {
					e.preventDefault();
				});
				getData();
			});
		</script>

	</body>

</html>